import 'package:amway_superapp_creator_plugin/utils/dev_util.dart';
import 'package:amway_superapp_creator_plugin/utils/sp_util.dart';
import 'package:dio/dio.dart';
import 'package:uuid/uuid.dart';

class TokenInterceptor extends Interceptor {
  var uuid = Uuid();

  @override
  onRequest(RequestOptions options) async {
    /// 在发送请求之前做一些预处理
    var v1 = uuid.v1();
    options.headers['Content-Type'] = 'application/json;charset=UTF-8';
    options.headers['Amway-Ada'] = SpUtil.getString("creater_amwayAda");
    options.headers['Amway-Id'] =  SpUtil.getString("creater_amwayId");
    options.headers['Avoid-Repeat-UUID']=v1;
    options.headers['Device-id'] = DevUtil.getDevId();
    return options;
  }

  @override
  onResponse(Response response) async {
    return response;
  }

  @override
  onError(DioError error) async {
    super.onError(error);
  }
}